"""
指定gpu : 设置某个gpu可见

"""
import tensorflow as tf 

tf.debugging.set_log_device_placement(True)

gpus = tf.config.experimental.list_logical_devices('GPU')
tf.config.experimental.set_visible_devices(gpus[0], 'GPU')  # 有4块 设置第一块GPU可见 即调用第一块GPU 
print(len(gpus))  # 物理设备4块

logical_gpus = tf.config.experimental.list_logical_devices('GPU')
print(len(logical_gpus))  # 逻辑设备1块
